package com.ymttest.business.service;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONObject;

import com.ymatou.iapi.login.parameter.SellerLoginBean;
import com.ymatou.iapi.userregister.parameter.SellerRegisterBean;
import com.ymatou.iapi.userregister.service.SellerRegisterCall;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/************************************************************************************
 * @File name :LiveShopUserCallService.java
 * @Author : zhouyi
 * @Date : 2018年3月13日
 * @Copyright : 洋码头
 * 直播微店相关
 ************************************************************************************/
public class LiveShopUserCallService {
	public static SellerRegisterBean initSellerReg() {
		SellerRegisterBean srb=new SellerRegisterBean();
		srb.setClientIp(TestDataManager.getRandomIp());
		srb.setDid(TestDataManager.getRandomUUID().toString());
		srb.setLid(TestDataManager.getRandomUUID().toString());
		srb.setLoginId("sr"+YMTDateUtil.getSysTime("MMddHHmmssSSS"));
		srb.setLoginMobile(TestDataManager.getPhoneNum("11"));
		srb.setPassword(JUserCallService.defaultLoginPwd);
		srb.setRegSource(7);
		srb.setTerminalSource(0);
		return srb;
	}
	/**
	 * 根据注册信息初始化登入信息
	 * @param srb
	 * @return
	 */
	public static SellerLoginBean initSellerlogin(SellerRegisterBean srb) {
		SellerLoginBean sellerloginBean=new SellerLoginBean();
		sellerloginBean.setClientIp(srb.getClientIp());
		sellerloginBean.setDid(srb.getDid());
		sellerloginBean.setLid(srb.getLid());
		sellerloginBean.setLoginMobile(srb.getLoginMobile());
		sellerloginBean.setPassword(srb.getPassword());
		sellerloginBean.setRegSource(srb.getRegSource());
		sellerloginBean.setTerminalSource(srb.getTerminalSource());
		return sellerloginBean;
	}
	/**
	 * @param srb
	 * @return userId token
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static JSONObject LiveShopSellerRegister(SellerRegisterBean srb) throws ClientProtocolException, IOException{
		SellerRegisterCall sellerregisterCall=new SellerRegisterCall();
		sellerregisterCall.setData(srb);
		sellerregisterCall.callService();
		return sellerregisterCall.getResult();
	}
}
